package com.etone.thread;

public class ThreadPractice extends Thread{

	public ThreadPractice(Runnable run){
		super(run);
	}
	@Override
	public void run() {
		System.out.println("?????????????" + this.getClass());
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Thread t = new ThreadPractice(new TestThread());
		t.start();
	}
	
	
	static class TestThread implements Runnable{

		@Override
		public void run() {
			System.out.println("!!!!!!!!" + this.getClass());
			
		}
	}
	
	static class TestThread1 implements Runnable{

		boolean b = true;
		@Override
		public void run() {
			while(!Thread.interrupted()){
				System.out.println(11111111);
			}
			
		}
		
	}
	
 static class TestThread2 implements Runnable{

	 int i =0;
	@Override
	public void run() {
		
		try {
			while(!Thread.interrupted()){
				System.out.println("\n\nThread is running! i =" + i);
				Thread.sleep(500);
				System.out.println("Thread is doing something! i =" + i);

			}
		} catch (InterruptedException e) {
			System.out.println("Thread are interrupting by exception! i =" + i);
			Thread.currentThread().interrupt();
			System.out.println("Thread interrupted status:" + Thread.interrupted());
			
		}
			System.out.println("Thread was exit!");
	}
	 
 }
}
